package com.czm.art_light.controller;

import com.czm.art_light.constant.ApiRouterConsts;
import com.czm.art_light.constant.SystemConfigConsts;
import com.czm.art_light.param.response.RestResp;
import com.czm.art_light.service.ArtResourceService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

/**
 * 资源(图片/视频/文档)模块 API 控制器
 */
@Tag(name = "资源管理", description = "资源相关接口")
@RestController
@RequestMapping(ApiRouterConsts.RESOURCE_API_URL_PREFIX)
@RequiredArgsConstructor
public class ArtResourceController {

    @Autowired
    private  ArtResourceService artResourceService;

    /**
     * 用户头像图片上传接口
     */
    @Operation(summary = "用户头像图片上传")
    @PostMapping("/uploadUserAvatarImage")
    public RestResp<String> uploadUserAvatarImage(@RequestParam("file") MultipartFile file) {
        return artResourceService.uploadImage(SystemConfigConsts.AVATAR_IMAGE_UPLOAD_DIRECTORY,file);
    }

    /**
     * 用户反馈图片上传接口
     */
    @Operation(summary = "用户反馈图片上传")
    @PostMapping("/uploadFeedbackImage")
    public RestResp<String> uploadFeedbackImage(@RequestParam("file") MultipartFile file){
        return artResourceService.uploadImage(SystemConfigConsts.FEEDBACK_IMAGE_UPLOAD_DIRECTORY,file);
    }
}
